from fastapi import APIRouter, Depends, HTTPException, status
from sqlalchemy.ext.asyncio import AsyncSession
from typing import List

from db.session import get_db
from schemas.settings import SettingsCreate, SettingsResponse, SettingsUpdate
from crud import settings as settings_crud

router = APIRouter(
    prefix="/settings",
    tags=["settings"],
    responses={404: {"description": "Settings not found"}},
)

@router.get("/", response_model=List[SettingsResponse])
async def get_settings(
    db: AsyncSession = Depends(get_db)
) -> List[SettingsResponse]:
    """
    Get all settings with pagination.
    
    Args:
        skip: Number of records to skip
        limit: Maximum number of records to return
        db: Database session dependency
        
    Returns:
        List of settings
    """
    return await settings_crud.get_settings(db)


@router.post("/", response_model=SettingsResponse, status_code=status.HTTP_201_CREATED)
async def create_settings(
    settings: SettingsCreate, 
    db: AsyncSession = Depends(get_db)
) -> SettingsResponse:
    """
    Create new settings.
    
    Args:
        settings: Settings data to create
        db: Database session dependency
        
    Returns:
        Created settings object
    """
    return await settings_crud.create_settings(db=db, settings=settings)
